package com.myapplication.ui.homefragment.shopfragment;

import android.util.Log;

import com.myapplication.bean.Banner;
import com.myapplication.bean.Shop;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by zitaojiang on 2016/10/8.
 */
public class Presenter_Shop implements Contract_Shop.Presenter {
    private Model_Shop mModel=new Model_Shop();
    private  Contract_Shop.view mView;
    private List<Shop.RowsBean> list;

    private List<Banner.AdListBean> Blist;
    public Presenter_Shop(final Contract_Shop.view mView) {
        this.mView = mView;
    }

    @Override
    public void putData() {
        mModel.getBanner(new Callback<Banner>() {
            @Override
            public void onResponse(Call<Banner> call, Response<Banner> response) {
                Blist=response.body().getAdList();
//                Log.i("tag","--------"+Blist.get(1).getImgUrl().length());
                mView.onGetBannerSuccess(Blist);
            }

            @Override
            public void onFailure(Call<Banner> call, Throwable t) {

            }
        });
    }


    @Override
    public void putData(Map<String, String> params) {
        mModel.getData(params, new Callback<Shop>() {
            @Override
            public void onResponse(Call<Shop> call, Response<Shop> response) {
            list=response.body().getRows();
             mView.onGetDataSuccess(list);
            }

            @Override
            public void onFailure(Call<Shop> call, Throwable t) {

            }
        });

    }
}
